

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import butines.core.GameAction;
import butines.core.GameCore;
import butines.core.GameCursor;
import butines.core.GameImage;
import butines.core.InputCodes;
import butines.core.gui.style.Box;
import butines.core.gui.style.HAlign;
import butines.core.gui.style.Text;
import butines.core.gui.style.VAlign;

public class TextTest extends GameCore {

    public static void main(String[] args) {
        new TextTest().startup();
    }

    private GameAction quit = new GameAction("Sair", GameAction.DETECT_INITAL_PRESS_ONLY);
    private GameAction toggle = new GameAction("toggle", GameAction.DETECT_INITAL_PRESS_ONLY);
    private GameAction play = new GameAction("play");
    private GameAction fullscreen = new GameAction("fullscreen", GameAction.DETECT_INITAL_PRESS_ONLY);
    private GameAction switchSize = new GameAction("switch size", GameAction.DETECT_INITAL_PRESS_ONLY);

    @Override
    public void init() {
        // TODO Auto-generated method stub

        defineActionKey(quit, InputCodes.KEY_ESC);
        defineActionKey(toggle, InputCodes.KEY_I);
        defineActionKey(play, InputCodes.KEY_SPACE);
        defineActionKey(fullscreen, InputCodes.KEY_F1);
        defineActionKey(switchSize, InputCodes.KEY_F2);

        setWindow(640, 480);
        setRelativeMouseMode(false);
        setSystemCursorVisible(true);
        setFrameRate(30);
        setGameCursor(new GameCursor(new GameImage("datas/ui/cursor_arrow.png")));
        
    }

    @Override
    public void destroy() {
        // TODO Auto-generated method stub

    }

    @Override
    public void update(float tpf) {

        if (quit.isPressed()) {
            shutdown();
        }
        if (toggle.isPressed()) {
            setRelativeMouseMode(!isRelativeMouseMode());
        }
        if (play.isPressed()) {
            playSound("datas/voice_select_3.wav", true);
        }
        if (fullscreen.isPressed()) {
            if (isFullScreen()) {
                setWindow(getWidth(), getHeight());
            } else {
                setFullScreen(getWidth(), getHeight());
            }
        }
        if (switchSize.isPressed()) {
            if (isFullScreen()) {
                if (getWidth() == 800) {
                    setFullScreen(640, 480);
                } else {
                    setFullScreen(800, 600);
                }
            } else {
                if (getWidth() == 800) {
                    setWindow(640, 480);
                } else {
                    setWindow(800, 600);
                }
            }
        }
    }

    Text text = new Text(new Font("Arial", Font.BOLD,  24), HAlign.CENTER, VAlign.MIDDLE, Color.GRAY, Color.WHITE, false);
    Text shadow = new Text(new Font("Arial", Font.BOLD,  24), HAlign.CENTER, VAlign.MIDDLE, Color.BLACK, Color.BLACK, false);

    Box boxup = new Box(); {
        boxup.round(16, new Color(73, 19, 18), new Color(255,255,255, 25));
        boxup.setSize(100, 50);
        boxup.setBackground(new Color(196, 51, 48), new Color(130, 32, 30));
    }
    
    Box boxdown = new Box(); {
        boxdown.round(16, new Color(73, 19, 18), new Color(0,0,0, 45));
        boxdown.setSize(100, 50);
        boxdown.setBackground(new Color(180, 42, 39), new Color(109, 25, 21));
    }
    
    @Override
    public void render(Graphics2D g2d) {
        g2d.setBackground(Color.white);
        g2d.clearRect(0, 0, getWidth(), getHeight());

        boxup.draw(g2d, 100, 100);
        shadow.draw(g2d, 102, 102, "Start!", 100, 50);
        text.draw(g2d, 100, 100, "Start!", 100, 50);
        
        boxdown.draw(g2d, 100, 200);
        shadow.draw(g2d, 102, 202, "Start!", 100, 50);
        text.draw(g2d, 100, 200, "Start!", 100, 50);
        
    }
    
    
}
